package crazy.io;

import java.io.FileInputStream;
import java.io.FileOutputStream;

public class FileOutputStreamTest
{

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception
	{
		FileInputStream fis = null;
		FileOutputStream fos = null;
		
		try
		{
			fis = new FileInputStream("D:\\workspace\\Algorithm\\src\\crazy\\io\\FileInputStreamTest.java");
			fos = new FileOutputStream("D:\\newFile.txt");
			byte[] bbuf = new byte[32];
			int hasRead = 0;
			while ((hasRead = fis.read(bbuf))>0)
			{
				fos.write(bbuf, 0, hasRead);
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			if (fis != null)
			{
				try
				{
					fis.close();
				}
				catch (Exception e2)
				{
					// TODO: handle exception
				}
			}
			
			if (fos != null)
			{
				try
				{
					fos.flush();
					fos.close();
				}
				catch (Exception e2)
				{
					// TODO: handle exception
				}
			}
		}
 
	}

}
